package com.foreknow.dao.impl;

import com.foreknow.dao.AdminDao;
import com.foreknow.db.DBManager;
import com.foreknow.db.JdbcTemplate;
import com.foreknow.mapping.EntityMapping;
import com.foreknow.mapping.MappingFactory;
import com.foreknow.model.Admin;

import java.sql.SQLException;
import java.util.List;

public class AdminDaoImpl extends BaseDAO implements AdminDao {

    @Override
    public Admin getNamePassword(String adminName, String password) throws SQLException {
        String sql = "select * from admin where adminName=? and password=?";
        EntityMapping mapping = mappingFactory.getMap(MappingFactory.ADMIN_MAPPING);
        List<Object> list = jdbcTemplate.query(sql,mapping,adminName,password);
        if (list.size()>0){
            Admin admin = (Admin) list.get(0);
            return admin;
        }
        return null;
    }
}
